﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using coliseu.BussinessLayer;

namespace coliseu.Views.Condominio
{
    public partial class FrmLisUsuario : Form
    {
        private UsuarioBL uBl = new UsuarioBL();
        private FuncionarioBL fbl = new FuncionarioBL();
        private GrupoBL gbl = new GrupoBL();
        public FrmLisUsuario()
        {
            InitializeComponent();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            FrmCadUsuario c = new FrmCadUsuario(uBl);
            c.ShowDialog();
            usuarioBindingSource.DataSource = uBl.selecionar();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            FrmCadUsuario u = new FrmCadUsuario(uBl, ((usuario)usuarioBindingSource.Current));
            u.ShowDialog();
            usuarioBindingSource.DataSource = uBl.selecionar();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Deseja excluir?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                uBl.excluir((usuario)usuarioBindingSource.Current);
                usuarioBindingSource.DataSource = uBl.selecionar();
            }
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            pnlFundo.Visible = true;
        }

        private void FrmLisUsuario_Load(object sender, EventArgs e)
        {
            grupoBindingSource.DataSource = gbl.selecionar();
            funcionarioBindingSource.DataSource = fbl.selecionar();            
            usuarioBindingSource.DataSource = uBl.selecionar();            
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            pnlFundo.Visible = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            pnlFundo.Visible = false;

            usuarioBindingSource.DataSource = uBl.selecionar(txtUsuario.Text);

        }
    }
}
